package com.newtouch.bxzs.business.train.controller;

import com.newtouch.bxzs.business.config.MyLog;
import com.newtouch.bxzs.business.train.model.bo.PerformanceBO;
import com.newtouch.bxzs.business.train.model.vo.PerformanceVO;
import com.newtouch.bxzs.business.train.service.PerformanceService;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 机构团队业绩controller
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/2/24 10:40</td>
 * <td>wangzhen</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author wangzhen
 * @version 1.0.0
 * @since 1.0.0
 */

@Api(tags = "机构团队业绩")
@RestController
@RequestMapping(value = "/performanceController")
@SuppressWarnings("unchecked")
public class PerformanceController {

	/**
	 * 静态变量：系统日志
	 */
	private static final Log logger = LogFactory.getLog(PerformanceController.class);

	@Autowired
	private PerformanceService performanceService;

	@PostMapping(value = "/getPerformance")
	@ApiOperation(value = "机构团队业绩汇总查询")
	@MyLog(systemFunctionName = "机构团队业绩汇总查询", systemFunctionUrl = "/memberInfoController/getPerformance", userOperationType = 4, userOperationSummary = "机构团队业绩汇总查询")
	public BaseResponse<List<PerformanceBO>> getPerformance(@RequestBody @Valid PerformanceVO performanceVO) {
		logger.info("机构团队业绩查询");
		List<PerformanceBO> performanceBO = performanceService.getPerformanceInfo(performanceVO);
		if (ObjectUtils.isEmpty(performanceBO)) {
			RespGenerator.returnError("未查询到符合条件的机构成员信息");
		}
		return RespGenerator.returnOK(performanceBO);
	}
}
